from car01 import Car
class Manager():
	def __init__(self):
		self.car_list = []

	# 展示车
	def show_cars(self):
		if self.car_list:
			for car in self.car_list:
				car.car_info()
		else:
			print("======\n\t所有枪已售罄！\n======")

	# 添加
	def add_car(self):
		name = input("枪型:")
		r = self.__has_car(name)
		if r is None:
			gun_seed = (input("枪种:"))
			price = int(input("价格:"))
			lethality = (input("杀伤力:"))
			bullet_bore = (input("子弹口径:"))
			penetrating_force = (input("穿透力:"))
			effective_range = (input("有效射程:"))
			car = Car(name, gun_seed, price, lethality, bullet_bore, penetrating_force, effective_range)
			self.car_list.append(car)
		else:
			car = self.car_list[r]
			car.count += 1
		print('上架成功'.center(30, '*'))

	# 判断是否已经存在（私有方法）
	def __has_car(self, name):
		name_list = [car.name for car in self.car_list]
		if name in name_list:
			return  name_list.index(name)
		else:
			return None